#import "YYText.h"
#import "dfhgwhruebvhrheyaluminiumdisorder.h"
@implementation dfhgwhruebvhrheyaluminiumdisorder {
	UIView *bgView;
	UIImageView *icon;
	UILabel *titleText;
	YYLabel *tipsText;
	UIButton *cancelBtn;
	UIButton *confirmBtn;
	CAGradientLayer *gradientLayer;
	void(^_click)(UIButton *sender);
}
- (instancetype)initWithFrame:(CGRect)frame {
	if(self = [super initWithFrame:frame]) {
		[self setUI];
	}
	return self;
}
- (void)setUI {
	self.backgroundColor = [UIColor clearColor];
	icon = [[UIImageView alloc] init];
	icon.image = [UIImage imageNamed:@"pop_warn_icon"];
	[self addSubview:icon];
	bgView = [[UIView alloc] init];
	bgView.layer.cornerRadius = 20;
	bgView.layer.masksToBounds = YES;
	bgView.backgroundColor = [UIColor whiteColor];
	[self addSubview:bgView];
	[self sendSubviewToBack:bgView];
	titleText = [[UILabel alloc] init];
	titleText.font = [UIFont medium:18];
	titleText.numberOfLines = 0;
	titleText.textAlignment = NSTextAlignmentCenter;
	titleText.textColor = @"#3B414B".dhgfywegwygeydwlearneddesignate;
	[bgView addSubview:titleText];
	tipsText = [[YYLabel alloc] init];
	tipsText.numberOfLines = 0;
	[bgView addSubview:tipsText];
	cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	cancelBtn.tag = 100;
	cancelBtn.layer.cornerRadius = 10;
	cancelBtn.backgroundColor = @"#EEEEEE".dhgfywegwygeydwlearneddesignate;
	cancelBtn.titleLabel.font = [UIFont medium:14];
	[cancelBtn setTitle:@"Cancel" forState:UIControlStateNormal];
	[cancelBtn setTitleColor:@"#AAAAAA".dhgfywegwygeydwlearneddesignate forState:UIControlStateNormal];
	[bgView addSubview:cancelBtn];
	[cancelBtn addTarget:self action:@selector(confirmBtnAction:) forControlEvents:UIControlEventTouchUpInside];
	confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	confirmBtn.tag = 101;
	confirmBtn.layer.cornerRadius = 10;
	confirmBtn.titleLabel.font = [UIFont medium:14];
	confirmBtn.backgroundColor = primary_color.dhgfywegwygeydwlearneddesignate;
	[confirmBtn setTitle:@"Confirm" forState:UIControlStateNormal];
	[confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
	[bgView addSubview:confirmBtn];
	[confirmBtn addTarget:self action:@selector(confirmBtnAction:) forControlEvents:UIControlEventTouchUpInside];
	gradientLayer = [CAGradientLayer layer];
	gradientLayer.startPoint = CGPointMake(0, 0);
	gradientLayer.endPoint = CGPointMake(0, 1);
	gradientLayer.colors = @[(__bridge  id)@"#E8F3FF".dhgfywegwygeydwlearneddesignate.CGColor, (__bridge  id)[UIColor whiteColor].CGColor];
	gradientLayer.locations = @[@(0.3), @(1.0)];
	[bgView.layer insertSublayer:gradientLayer atIndex:0];
}
- (void)confirmBtnAction:(UIButton *)sender {
	if(_click) {
		_click(sender);
	}
}
- (void)configure:(NSString *)title andTips:(NSString *)text withBtnsClick:(void(^)(UIButton *sender))click {
	_click = click;
	tipsText.text = text;
	titleText.text = title;
	CGSize titleSize = [titleText sizeThatFits:CGSizeMake(self.php_w - 40, CGFLOAT_MAX)];
	[titleText mas_updateConstraints:^(MASConstraintMaker *make) {
		make.height.mas_equalTo(titleSize.height);
	}];
	CGSize tipSize = [tipsText sizeThatFits:CGSizeMake(self.php_w - 40, CGFLOAT_MAX)];
	[tipsText mas_updateConstraints:^(MASConstraintMaker *make) {
		make.height.mas_equalTo(tipSize.height);
	}];
	NSMutableAttributedString *tipsAttribute = [[NSMutableAttributedString alloc] initWithString:text];
	tipsAttribute.yy_color = @"#3B414B".dhgfywegwygeydwlearneddesignate;
	NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
	style.lineSpacing = 5;
	tipsAttribute.yy_paragraphStyle = style;
	tipsAttribute.yy_font = [UIFont regular:14];
	tipsText.attributedText = tipsAttribute;
}
- (void)layoutSubviews {
	[super layoutSubviews];
	[icon mas_makeConstraints:^(MASConstraintMaker *make) {
		make.top.centerX.equalTo(self);
		make.size.mas_equalTo(CGSizeMake(62, 62));
	}];
	[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.top.equalTo(self).offset(31);
		make.left.bottom.right.equalTo(self);
	}];
	[titleText mas_makeConstraints:^(MASConstraintMaker *make) {
		make.top.equalTo(bgView).offset(49);
		make.centerX.equalTo(bgView);
		make.left.equalTo(bgView).offset(20);
		make.height.mas_equalTo(25).priorityHigh();
	}];
	[tipsText mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerX.equalTo(bgView);
		make.left.equalTo(bgView).offset(20);
		make.height.mas_equalTo(60).priorityHigh();
		make.top.equalTo(titleText.mas_bottom).offset(20);
	}];
	[cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
		make.bottom.equalTo(bgView).offset(-20);
		make.size.mas_equalTo(CGSizeMake(110, 38));
		make.left.equalTo(bgView).offset((self.bounds.size.width - 220 - 20)/2);
	}];
	[confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
		make.size.centerY.equalTo(cancelBtn);
		make.left.equalTo(cancelBtn.mas_right).offset(20);
	}];
	[self layoutIfNeeded];
	gradientLayer.frame = bgView.bounds;
}
@end
